unit Class_TaskDetail;

interface
uses
  ADODB,DB,Classes,SysUtils;
type
  TTaskDetail=class(TObject)
  private
    FADOCon:TADOConnection;
    FTestCount:Integer;
  public
    ID:Integer;
    Code:string;
  public
    procedure InsertDB(AADOCon:TADOConnection);
    procedure TestSave;
  public
    property ADOCon:TADOConnection read FADOCon write FADOCon;
    property TestCount:Integer read FTestCount write FTestCount;
  end;


implementation

{ TTaskDetail }

procedure TTaskDetail.InsertDB(AADOCon: TADOConnection);
var
  ADOCmd:TADOCommand;
begin
  try
    ADOCmd:=TADOCommand.Create(nil);
    if AADOCon=nil then
    begin
      ADOCmd.Connection:=ADOCon;
    end else
    begin
      ADOCmd.Connection:=AADOCon;
    end;
    ADOCmd.Prepared:=True;

    ADOCmd.CommandText:='Insert Into TBL_TaskDetail (Code ) Values(:Code)';
    ADOCmd.Parameters.ParamByName('Code').Value:=Code;
    ADOCmd.Execute;
  finally
    FreeAndNil(ADOCmd);
  end;
end;


procedure TTaskDetail.TestSave;
var
  I:Integer;
begin
  for I:=0 to TestCount-1 do
  begin
    Code:=IntTostr(I);
    InsertDB(ADOCon);
  end;
end;

end.
